<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>备份的表</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="/favicon.ico">
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="/static/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <!-- Sweet Alert -->
    <link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h2>{$table} - 数据表备份信息</h2>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="table table-striped table-responsive table-bordered table-hover" id="editable">
                        <thead>
                        <tr>
                            <th>备份时间</th>
                            <th>备份名称</th>
                            <th>文件大小</th>
                            <th>类型</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $list as $v}
                        <tr>
                            <td>{:date("Y/m/d H:i:s", $v.time)}</td>
                            <td>{$v.filename}</td>
                            <td>{:format_size($v.size)}</td>
                            <td>{$v.compress}</td>
                            <td>
                                <a href="javascript:;" onclick="recycle('{$table}', '{$v.time}')"
                                   class="btn btn-success btn-sm">数据还原</a>
                                <a href="javascript:;" onclick="delTable('{$table}', '{$v.time}')"
                                   class="btn btn-primary btn-sm">删除备份</a>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>


<script src="/static/admin/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="/static/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/static/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="/static/admin/js/content.js?v=1.0.0"></script>

<!-- Sweet alert -->
<script src="/static/admin/js/plugins/sweetalert/sweetalert.min.js"></script>


<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        $('#editable').dataTable();
    });

    function recycle(tablename, time) {
        $.post("{:url('admin/Database/recycle')}", {t: tablename, time: time}, function (res) {
            if (res.code === 1) {
                swal(res.msg, res.msg, "success");
                setTimeout(function () {
                    location.reload();
                }, 2000);
            } else {
                swal(res.msg, res.msg, "error");
            }
        }, 'json');
    }

    function delTable(tablename, time) {
        $.post("{:url('admin/Database/del')}", {t: tablename, time: time}, function (res) {
            if (res.code === 1) {
                swal(res.msg, res.msg, "success");
                setTimeout(function () {
                    location.reload();
                }, 2000);
            } else {
                swal(res.msg, res.msg, "error");
            }
        }, 'json');
    }
</script>

</body>

</html>
